package com.xilihui.xlh.business.dialogs;

import android.app.Activity;
import android.app.Dialog;
import android.view.Gravity;
import android.view.View;

import com.xilihui.xlh.R;
import com.xilihui.xlh.core.util.YEventBuses;

/**
 * Created by Administrator on 2018/8/16.
 */

public class PayDialog implements View.OnClickListener {
    
    Activity activity;
    Dialog dialog;
    private OnItemSelectListener listener;

    public PayDialog(Activity activity){
        this.activity  = activity;
        
        dialog = new Dialog(activity,R.style.Dialog);
        dialog.setContentView(R.layout.dialog_pattern);
        dialog.setCancelable(true);
        dialog.getWindow().setGravity(Gravity.BOTTOM);
        dialog.setCanceledOnTouchOutside(true);
        
        initView();
    }
    
    public void initView(){
        dialog.findViewById(R.id.iv_close).setOnClickListener(this);
        dialog.findViewById(R.id.alipay).setOnClickListener(this);
        dialog.findViewById(R.id.weixin).setOnClickListener(this);
    }
    
    public void show(){
        dialog.show();
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.iv_close:
                dialog.dismiss();
                break;
            case R.id.alipay:
                listener.alipay();
                dialog.dismiss();
                break;
            case R.id.weixin:
                listener.weixin();
                dialog.dismiss();
                break;
        }
        
    }
    
    public interface OnItemSelectListener{
        void close();
        void alipay();
        void weixin();
    }
    
    public void setOnItemSelectListener(OnItemSelectListener listener){
        this.listener = listener;
    }
    
}
